package org.demo.multisource.controller;

import lombok.RequiredArgsConstructor;
import org.demo.multisource.service.StudentService;
import org.demo.multisource.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController()
@RequestMapping("/test")
@RequiredArgsConstructor(onConstructor=@__({@Autowired,@Lazy}))
public class TestController {

    private final StudentService studentService;
    private final TeacherService teacherService;

    @GetMapping("/hello")
    public Object hello(){
        Map<String,Object> map = new HashMap<>();
        map.put("msg","hello");
        return map;
    }

    @GetMapping("/student/add")
    public Object addStudent(){
        Map<String,Object> map = new HashMap<>();
        map.put("msg","add student");
        studentService.cusAdd();
        return map;
    }

    @GetMapping("/teacher/add")
    public Object addTeacher(){
        Map<String,Object> map = new HashMap<>();
        map.put("msg","add teacher");
        teacherService.cusAdd();
        return map;
    }
}
